//
//  BrandActivityTableViewCell.m
//  UGoods
//
//  Created by dllo on 16/1/21.
//  Copyright © 2016年 蓝鸥科技.李贺. All rights reserved.
//

#import "BrandActivityTableViewCell.h"
#import "BaseView.h"
#import "ConstantsDefine.h"
@interface BrandActivityTableViewCell ()

@property (nonatomic, retain) BaseView *backView;

@end


@implementation BrandActivityTableViewCell

- (void)dealloc
{
    [_backView release];
    [_alabel release];
    [super dealloc];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.backView = [[BaseView alloc] init];
        [self.contentView addSubview:_backView];
        [_backView release];
        
        self.alabel = [[BaseLabel alloc] init];
        //        self.alabel.backgroundColor = [UIColor redColor];
        self.alabel.numberOfLines = 0;
        _alabel.textColor = [UIColor grayColor];
        _alabel.font = [UIFont systemFontOfSize:13 * WIDTH];
        [self.contentView addSubview:_alabel];
        [_alabel release];
        
    }
    return self;
}

// 计算_alabelLabel高度
+ (CGFloat)heightWithText:(NSString *)text {
    
    CGRect rect = [text boundingRectWithSize:CGSizeMake(375 * WIDTH - 20 * WIDTH, 1000 * HEIGHT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:13 * WIDTH]} context:nil];
    
    return rect.size.height;
}

- (void)layoutSubviews {
    [super layoutSubviews];
    self.backView.frame = CGRectMake(0, 0, self.contentView.frame.size.width, self.contentView.frame.size.height - 10 * HEIGHT);
    
    CGFloat h = [[self class] heightWithText:_alabel.text];
    _alabel.frame = CGRectMake(10 * WIDTH, 0, self.contentView.frame.size.width - 20 * WIDTH, h * HEIGHT);
    
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
